
/*
 *  Openmysee
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 */
//

#include "stdafx.h"
#include "GVCapture.h"
#include "AudioCompressSelectorDlg.h"
#include "capture.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CAudioCompressSelectorDlg dialog


CAudioCompressSelectorDlg::CAudioCompressSelectorDlg(CCaptureGraph *pCG, CWnd* pParent /*=NULL*/)
	: CDialog(CAudioCompressSelectorDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CAudioCompressSelectorDlg)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT

	m_pCG = pCG;
}


void CAudioCompressSelectorDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CAudioCompressSelectorDlg)
	DDX_Control(pDX, IDC_LIST_AUDIO_FORMAT, m_lsAudioFormat);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CAudioCompressSelectorDlg, CDialog)
	//{{AFX_MSG_MAP(CAudioCompressSelectorDlg)
	ON_WM_DESTROY()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CAudioCompressSelectorDlg message handlers

void CAudioCompressSelectorDlg::OnOK() 
{	
	int i;
	if((i = m_lsAudioFormat.GetCurSel()) != LB_ERR)
	{
		AM_MEDIA_TYPE * pamt = (AM_MEDIA_TYPE *)(m_lsAudioFormat.GetItemDataPtr(i));
		m_pCG->SetAudioWaveformat(pamt);
	}

	CDialog::OnOK();
}

void CAudioCompressSelectorDlg::OnCancel() 
{	
	m_pCG->SetAudioWaveformat(NULL);
	CDialog::OnCancel();
}

BOOL CAudioCompressSelectorDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	m_pCG->EnumAudioWaveFormat(&m_lsAudioFormat);

	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CAudioCompressSelectorDlg::OnDestroy() 
{
	for(int i = 0; i < m_lsAudioFormat.GetCount(); i++)
		HeapFree(GetProcessHeap(), 0, m_lsAudioFormat.GetItemDataPtr(i));

	CDialog::OnDestroy();	
}
